package com.jiacl.controller;

import com.jiacl.entity.core.Result;
import com.jiacl.form.SurnameForm;
import com.jiacl.service.SurnameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;

/**
 * Created by XiaoWei on 2017/9/2.
 */
@Controller
@RequestMapping("/surname")
public class SurnameController {

    @Autowired
    private SurnameService surnameService;

    @GetMapping("/getSurname/{id}")
    public ResponseEntity<Result> selectSurnameByEareId(HttpSession session, @PathVariable("id")Integer id) throws Exception{
        if(id<=0){
            return ResponseEntity.ok(new Result());
        }
        Result result = surnameService.selectJiaclSurname(id);
        return ResponseEntity.ok(result);
    }

    @GetMapping("/getSurnameAll")
    public ResponseEntity<Result> selectSurnameAll(SurnameForm surnameForm) throws Exception{
        Result result = surnameService.selectSurnameAll(surnameForm);
        return ResponseEntity.ok(result);
    }
    @GetMapping("/getSurnameAllPhonetic")
    public ResponseEntity<Result> getSurnameAllPhonetic() throws Exception{
        Result result = surnameService.selectSurnameAll();
        return ResponseEntity.ok(result);
    }

}
